<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var year = Number(prompt("请你输入你的出生年份"));
      var moth = Number(prompt("请你输入你的出生月份"));
      var nowyear = new Date().getFullYear();
      var nowmoth = new Date().getMonth() + 1;
      if (year <= nowyear && moth < 12) {
        if (year < nowyear && moth <= nowmoth) {
          var a = nowyear - year;
          document.write(`你的年龄是${a}岁`);
        } else if (year < nowyear && moth > nowmoth) {
          var a = nowyear - year - 1;
          document.write(`你的年龄是${a}岁`);
        } else if ((year = nowyear && moth <= nowmoth)) {
          document.write("你的年龄是0岁");
        }
      } else {
        document.write("输入错误请重新输入");
      }
    </script>
  </body>
</html>
